package com.bzkj.basicinfo.service.basic.impl;

import com.bzkj.basicinfo.domain.basic.BasicStoArea;
import com.bzkj.basicinfo.domain.basic.BasicStoStock;
import com.bzkj.basicinfo.mapper.BasicStoStockMapper;
import com.bzkj.basicinfo.service.basic.BasicStoStockService;
import com.bzkj.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collections;
import java.util.List;

/**
 * @author wl
 * @description 针对表【basic_sto_stock(WMS仓库信息表)】的数据库操作Service实现
 * @createDate 2024-12-13 10:42:22
 */
@Slf4j
@Service
public class BasicStoStockServiceImpl implements BasicStoStockService {
    @Autowired
    private BasicStoStockMapper basicStoStockMapper;

//    @Autowired
//    private BasicStoStockRuleMapper basicStoStockRuleMapper;

    /**
     * 获取库区信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 12:17:59
     * @Param entity
     */
    @Override
    public List<BasicStoArea> findBasicStoStockData(BasicStoArea entity) {
        List<BasicStoArea> list = basicStoStockMapper.findBasicStoStockData(entity);
        return list;
    }

    @Override
    public List<BasicStoArea> findAllBasicStoStockData(BasicStoArea entity) {
        List<BasicStoArea> list = basicStoStockMapper.findAllBasicStoStockData(entity);
        return list;
    }

    /**
     * 仓库状态修改
     *
     * @param status
     * @param stoId
     * @return
     */
    @Override
    public AjaxResult updateBasicStoStockEnableStatus(String status, String stoId) {
        try {
            basicStoStockMapper.updateBasicStoStockEnableStatus(status, stoId);
            return AjaxResult.success("修改成功");
        } catch (Exception e) {
            log.error("修改失败:{}", e);
            return AjaxResult.error("修改失败");
        }
    }

    @Override
    public AjaxResult updateBasicStoStockWmsEnableStatus(String status, String stoId) {
        try {
            basicStoStockMapper.updateBasicStoStockWmsEnableStatus(status, stoId);
            return AjaxResult.success("修改成功");
        } catch (Exception e) {
            log.error("修改失败:{}", e);
            return AjaxResult.error("修改失败");
        }
    }

    @Override
    public List<String> selectWarehouseListByUserId(Long userId) {
        return basicStoStockMapper.selectWareHouseListByUserId(userId);
    }

    @Override
    public BasicStoArea queryOneByStoId(String stoId) {
        return basicStoStockMapper.selectOneByStoId(stoId);
    }

    @Override
    public List<BasicStoStock> selectAllBasicStoStock(String stoCode, String stoName) {
        return basicStoStockMapper.findStoStock(stoCode, stoName);
    }

    @Override
    public AjaxResult queryAllStoStock(String mode, String stoId, String stoCode, String stoName,String stoAreaId,String flag) {
        return AjaxResult.success(basicStoStockMapper.findWmsWarehouseInfo(mode, stoId, stoCode, stoName, stoAreaId, flag));

    }
}




